package com.example.twoeightgang;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import android.view.WindowManager;

public class BackGroundView extends View {
    private Paint paint;
    //WindowManager windowManager = (WindowManager) this.getContext().getSystemService(Context.WINDOW_SERVICE);

//    public BackGroundView(Context context) {
//        super(context);
//    }
public BackGroundView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

    @SuppressLint("ResourceAsColor")
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        setBackgroundColor(R.color.colorBlue);

        //int weith = windowManager.getDefaultDisplay().getWidth();
        //int height = windowManager.getDefaultDisplay().getHeight();
        paint = new Paint();
        paint.setColor(Color.GRAY);
        paint.setStyle(Paint.Style.FILL); //FILL填充内部；STROKE不填充，硬笔线；FILL_AND_STROKE和FILL没有看出明显不同
        paint.setAntiAlias(true);// 消除锯齿
        paint.setStrokeWidth(1);// 设置paint的外框宽度
        canvas.drawRect(0, 0, 0, 0, paint);//绘制矩形
    }
}
